#ifndef errors_h__
#define errors_h__

#include <iosfwd>
#include <stdexcept>
#include <string>
namespace CCompiler
{

    namespace Errors
    {
        class BrokenStream{};
		class EndOfFile{};
		class CmdOptionsError{};
		class BaseErrorWithMsg
		{
		protected:
			std::string msg_;
		public:
			BaseErrorWithMsg(const std::string &msg = ""):
			msg_(msg) {}
			friend std::ostream &operator<<(std::ostream &stream, const BaseErrorWithMsg& error)
			{
			  return stream << error.msg_;
			}			
		};
		class SyntaxError: public BaseErrorWithMsg
		{
		public:
			SyntaxError(const std::string &msg): BaseErrorWithMsg(msg) {}
		};
		class TokenError: public BaseErrorWithMsg
		{
			int line_, pos_;
			std::string originalText_;
		public:
			TokenError(const std::string &msg, int line, int pos, const std::string &originalText):
				BaseErrorWithMsg(msg),
				line_(line),
				pos_(pos),
				originalText_(originalText)
			{}

			friend std::ostream &operator<<(std::ostream &stream, const TokenError& error)
			{
				stream << '[' << error.line_ << ',' << error.pos_ << ']';
				stream << " Type: " << "ERROR";
				stream << " T: " << error.originalText_;
				stream << " S: " << error.msg_;
				return stream << std::endl;
			}			

		};
    }
}

#endif // errors_h__
